<!--
 * @Descripttion: 
 * @version: 
 * @Author: ada.wu
 * @Date: 2025-07-02 02:24:59
 * @LastEditors: ada.wu
 * @LastEditTime: 2025-07-03 09:24:25
-->
<div class="layuimini-main">
    <div class="layui-form layuimini-form">
        <div class="layui-form-item">
            <label class="layui-form-label required">班次名称</label>
            <div class="layui-input-block">
                <input type="text" name="username" lay-verify="required" lay-reqtext="班次名称不能为空" placeholder="请输入班次名称"
                    value="" class="layui-input">
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label required">班次类型</label>
            <div class="layui-input-block">
                <select name="interest" placeholder="请选择">
                    <option value="0">普通班次</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">岗位分类</label>
            <div class="layui-input-block">
                <select name="interest" placeholder="请选择">
                    <option value=""></option>
                    <option value=" 0">巡查/安全</option>
                    <option value="1" selected>环卫绿化/环卫保洁</option>
                    <option value="2">巡查/综合巡查</option>
                    <option value="3">环卫绿化</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">适用职位</label>
            <div class="layui-input-block">
                <select name="ganwei" placeholder="请选择">
                    <option value=""></option>
                    <option value="0">巡查/安全</option>
                    <option value="1" selected>环卫绿化/环卫保洁</option>
                    <option value="2">巡查/综合巡查</option>
                    <option value="3">环卫绿化</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排班时间</label>
            <div class="layui-input-block">
                <div class="flex items-center">
                    <input name="laydate-1" type="text" class="layui-input" id="ID-laydate-1" placeholder="上班时间">
                    <div class="mx-1">-</div>
                    <input name="laydate-2" type="text" class="layui-input" id="ID-laydate-2" placeholder="下班时间">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">休息时间</label>
            <div class="layui-input-block">
                <div class="flex items-center">
                    <input name="laydate-3" type="text" class="layui-input" id="ID-laydate-3" placeholder="开始时间">
                    <div class="mx-1">-</div>
                    <input name="laydate-4" type="text" class="layui-input" id="ID-laydate-4" placeholder="结束时间">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="flex-center">
                <button class="layui-btn layui-btn-primary layui-btn-sm btn-70" lay-on="closeBtn">取消</button>
                <button class="layui-btn layui-btn-normal layui-btn-sm btn-70" lay-submit
                    lay-filter="saveBtn">保存</button>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form', 'table'], function () {
        var form = layui.form,
            layer = layui.layer,
            laydate = layui.laydate,
            table = layui.table,
            util = layui.util,
            $ = layui.$;

        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();

        // 渲染
        laydate.render({
            elem: '#ID-laydate-1',
            type: 'time',
            format: 'HH:mm'
        });
        laydate.render({
            elem: '#ID-laydate-2',
            type: 'time',
            format: 'HH:mm'
        });
        laydate.render({
            elem: '#ID-laydate-3',
            type: 'time',
            format: 'HH:mm'
        });
        laydate.render({
            elem: '#ID-laydate-4',
            type: 'time',
            format: 'HH:mm'
        });

        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;

        // 获取存储的数据
        var appData = layui.sessionData('SHIFT_PARAMS')
        let { dataDto = null, pageType = '' } = appData
        if (dataDto) {
            dataDto = JSON.parse(dataDto)
        }
        console.log('子页面的值===', pageType, dataDto)

        // 普通事件
        util.on('lay-on', {
            // 关闭弹出层
            "closeBtn": function () {
                layer.close(parentIndex);

            }
        });




        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var index = layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            }, function () {

                // 关闭弹出层
                layer.close(index);
                layer.close(parentIndex);

            });


            return false;
        });

    });
</script>